<template>
  <el-select
    v-model="value"
    style="width: 240px"
  >
    <el-option
      v-for="item in options"
      :key="item.key"
      :label="item.label"
      :value="item.value"
      :disabled="item.disabled"
    />
  </el-select>
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import { ICellEditorParams } from 'ag-grid-community';
import OptionVO from '@/bean/vo/OptionVO';
import AgColumn from '@/bean/vo/AgColumn';


const props = defineProps<{
  params: ICellEditorParams;
}>();

const options = ref<OptionVO[]>(getOptions(props.params.colDef.cellEditorParams));

const value = ref(props.params.value);

function getOptions(optionsFunc: AgColumn<any>['options']) {
  const options = typeof optionsFunc === 'function' ? optionsFunc(props.params) : optionsFunc;
  return options || [];
}

function getValue() {
  return value.value;
}

defineExpose({
  getValue
});
</script>
